﻿using System;
using System.Collections.Generic;


namespace ValidationFramework.Web.MVC
{
	public class ClFunctionCallProviderDictionary : Dictionary<RuntimeTypeHandle, IClientFunctionCallProvider>
	{
		public IClientFunctionCallProvider GetProvider(ISpecification validator)
		{
			Type validatorType = validator.GetType();

			IClientFunctionCallProvider provider;
			// We need to force the consumer to provide providers explicitly per type.
			//if (validatorType.IsGenericType)
			//{
			//    this.TryGetValue(validatorType.GetGenericTypeDefinition().TypeHandle, out provider);
			//}
			//else
			//{
				this.TryGetValue(validator.GetType().TypeHandle, out provider);
			//}

			return provider;
		}
	}
}
